home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / progrmng / exmpldrw.sit / For MPW / Converter next >
Encoding:
Text File  |  1990-07-01  |  1.4 KB  |  71 lines  |  [TEXT/MPS ]

  1. #    Applies changes described in a set of difference files.
  2. #    Larry Rosenstein 6/30/90
  3.  
  4. #    To create the difference file do:
  5. #        compare -v <newfile> <oldfile> > <oldfile>.Diff
  6.  
  7. #    To apply the differences, do:
  8. #        Converter
  9. #    and select the directories containing the files to be converted and the 
  10. #    difference files.  The script will perform the conversion and rename the
  11. #    original file to "<file>.original".
  12.  
  13. #
  14.  
  15. set iDir `getfilename -d -m 'Select Source directory.'`
  16. set dDir `getfilename -d -m 'Select Diffs directory.'`
  17.  
  18. for file in `files -s -f "{dDir}"┼.Diff`
  19.     if "{file}" =~ /┼:(┼)¿1.Diff/
  20.         set src "{iDir}{¿1}"
  21.         set diff "{file}"
  22.         set cvt "{src}.converted"
  23.     
  24.         echo "Converting {src}."
  25.         
  26.         duplicate "{src}" "{cvt}"
  27.         target "{diff}"; find ░
  28.         
  29.         loop
  30.             target "{diff}"; find \Ñ┼╢(File\ || break
  31.             
  32.             if "`catenate ñ`" =~ /(┼)¿1┼/ 
  33.                 set change "{¿1}"
  34.             end
  35.             
  36.             find /Line [┬;]+;/
  37.             if "`catenate ñ`" =~ /Line ([┬;]+)¿1;/ 
  38.                 set newSel "{¿1}"
  39.             end
  40.             
  41.             find /Line ┼╢)/
  42.             if "`catenate ñ`" =~ /Line (┼)¿1╢)/ 
  43.                 set oldSel "{¿1}"
  44.             end
  45.             
  46.             find ╞!1
  47.             if "{newSel}" =~ /([0-9]+)¿8:([0-9]+)¿9/
  48.                 copy ñ:!`evaluate "{¿9}"-"{¿8}"`
  49.             else
  50.                 copy !0
  51.             end
  52.  
  53.             target "{cvt}"
  54.             if "{change}" =~ /extra lines in 2┼/
  55.                 clear {oldSel}
  56.             else
  57.                 find {oldSel}
  58.                 paste ñ
  59.             end
  60.             
  61.             target "{diff}"; find \Ñ┼╢(File┼░\
  62.         end
  63.     end
  64.     
  65.     close -y "{cvt}"
  66.     close -n "{diff}"
  67.     
  68.     rename "{src}" "{src}.original"
  69.     rename "{cvt}" "{src}"
  70. end
  71.